package org.fullhappy.bean;

import java.io.IOException;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;

import org.fullhappy.business.ArticleServise;
import org.fullhappy.entity.Article;
@ManagedBean
@SessionScoped
public class AddArticleBean {
	private Article article = new Article();
	private ArticleServise articleServise = new ArticleServise();
	
	public void add(){
		long articleId ;
		articleServise.addArticle(article);
		articleId = article.getArticleID();
		article = new Article();
			try {
				FacesContext.getCurrentInstance().getExternalContext().redirect("./detail_article.happy?itemId="+articleId);
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
	}

	public Article getArticle() {
		return article;
	}

	public void setArticle(Article article) {
		this.article = article;
	}

	public ArticleServise getArticleServise() {
		return articleServise;
	}

	public void setArticleServise(ArticleServise articleServise) {
		this.articleServise = articleServise;
	}
	
	
}
